import { SERVICE_PHONE_NUMBER } from "../../utils/constant";
import { verify } from "../../utils/http";
import { enter } from "../../utils/util";

// pages/profile/profile.ts
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		userOrderList: [
			{
				icon: 'wallet',
				label: '待付款',
				status: 0
			},
			{
				icon: 'task-time',
				label: '待服务',
				status: 3
			},
			{
				icon: 'user-time',
				label: '进行中',
				status: 4
			},
			{
				icon: 'data-checked',
				label: '已完成',
				status: 5
			},
		],
		pageList: [
			{
				icon: 'location',
				label: '地址管理',
				page: '/pages/chooseAddress/chooseAddress?type=view'
			},
			{
				icon: 'service',
				label: '客服',
				page: '',
				makePhoneCall: SERVICE_PHONE_NUMBER
			},
			{
				icon: 'usergroup-add',
				label: '被服务对象',
				page: '/pages/familyMembers/familyMembers'
			},
		]
	},

	hanldePageItem(e: WechatMiniprogram.CustomEvent) {
		if (e.currentTarget.dataset.makePhoneCall) {
			wx.makePhoneCall({
				phoneNumber: e.currentTarget.dataset.makePhoneCall
			});
		} else if (e.currentTarget.dataset.page) {
			enter({url: e.currentTarget.dataset.page});
		}
	},

	toUserOrderList(e: WechatMiniprogram.CustomEvent) {
		enter({
			pageName: 'userOrderList',
			query: {
				status: String(e.currentTarget.dataset.status)
			}
		})
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad() {
		phone: ''
	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady() {
		this.setData({
			phone: wx.getStorageSync("phone")
		});
	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow() {
		verify();
	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage() {

	}
})